<?php
/**
 * Domain Menu
 * @author Tomas Srna
 * @package bakalarka
 */

class DomainMenu extends Menu
{
	protected $_children = array();
	
	public function __construct()
	{
		$domains = Selector::select()->from(DomainModel::struct())
						->order('name')
						->fetch();
		
		$c = Config::$itemsPerMenu;
		foreach ($domains as $domain) {
			if($c <= 0)
			{
				--$c;
				break;
			}
			
			if(Acl::instance()->allowed('domain:'.$domain->name))
				$this->_children[] = new Link($domain->name, 
					'domain:'.$domain->name, 'domain', $domain->name);
			else
				continue;
			
			--$c;
		}
		
		// Este nam ostava domena
		if($c < 0)
			$this->_children[] = 
				new Link(L::selected()->more, 'domain:*', 'domain');
	}
	
	public function children()
	{
		return $_children;
	}
}
